<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>12.原型链检测之instanceof</title>
</head>

<body>
  <script>
    //instanceof 检测构造函数的 prototype 属性是否出现在某个实例对象的原型链上
    function A () { }
    function B () { }
    function C () { }

    const c = new C();
    B.prototype = c;
    const b = new B();
    A.prototype = b;
    const a = new A();

    console.dir(a instanceof A); //true
    console.dir(a instanceof B); //true
    console.dir(a instanceof C); //true
    console.dir(b instanceof C); //true
    console.dir(c instanceof B); //false
  </script>
</body>

</html>